package com.xuzimian.global.demo.spring.security.oauth2.client.config.oauth;


import com.xuzimian.global.demo.spring.security.oauth2.client.filter.QQAuthenticationFilter;
import com.xuzimian.global.demo.spring.security.oauth2.client.filter.QQAuthenticationManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

/**
 * 该类配置oauth2 client客户端，用于自己的QQ 的 oauth2 server登录授权。
 * 1.因为回调地址不是 http://localhost ，所以在启动时，需要在host文件中添加一行：127.0.0.1:8080 www.ictgu.cn
 * 前端配置链接：
 * <a href="https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=101386962&redirect_uri=http://www.ictgu.cn/login/qq&state=test" class="btn btn-primary btn-block">QQ登录</a>
 */
@Configuration
@Order(Integer.MIN_VALUE)
public class OAuth2ClientFoQQOauthServerConfigurer {

    @Bean(name = "qqFilter")
    public QQAuthenticationFilter qqAuthenticationFilter() {
        QQAuthenticationFilter authenticationFilter = new QQAuthenticationFilter("/login/qq");
        authenticationFilter.setAuthenticationManager(new QQAuthenticationManager());
        return authenticationFilter;
    }
}
